//
//  LikerListCell.m
//  TourPlay
//
//  Created by dllo on 15/11/24.
//  Copyright © 2015年 王军岐. All rights reserved.
//

#import "LikerListCell.h"

@interface LikerListCell ()

@property (nonatomic, retain) UIImageView *imageV;
@property (nonatomic, retain) UILabel *nameL;

@end

@implementation LikerListCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (void)createSubViews
{
    
    UIImageView *imageBack = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, 50, 50)];
    imageBack.backgroundColor = [UIColor whiteColor];
    imageBack.layer.masksToBounds = YES;
    imageBack.layer.cornerRadius = (imageBack.frame.size.width) / 2.f;
    // 边框宽度
    imageBack.layer.borderWidth = 1;
    // 边框颜色
    imageBack.layer.borderColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1].CGColor;
    [self.contentView addSubview:imageBack];
    [imageBack release];
    
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, imageBack.frame.size.width - 4, imageBack.frame.size.height - 4)];
//    self.imageV.backgroundColor = [UIColor orangeColor];
    self.imageV.contentMode = UIViewContentModeScaleAspectFill;
    self.imageV.layer.masksToBounds = YES;
    self.imageV.layer.cornerRadius = (self.imageV.frame.size.width) / 2.f;
    
  
    [imageBack addSubview:self.imageV];
    [_imageV release];
    
    self.nameL = [[UILabel alloc] initWithFrame:CGRectMake(imageBack.frame.origin.x + imageBack.frame.size.width + 20, 0, SCREEN_WIDTH - imageBack.frame.size.width - imageBack.frame.origin.x - 40, 69.f)];
//    self.nameL.backgroundColor = [UIColor orangeColor];
//    self.nameL.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.nameL];
    [_nameL release];
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(self.nameL.frame.origin.x, self.nameL.frame.size.height - 1, self.nameL.frame.size.width, 1)];
    view.backgroundColor = [UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1];
    [self.contentView addSubview:view];
    [view release];
    
    [self addColorChangedBlock:^{
        
        self.nameL.nightTextColor = [ColorSingleton shareSingleton].cellTitleColor;
        self.nameL.normalTextColor = [ColorSingleton shareSingleton].cellTitleColor;
        
        view.nightBackgroundColor = [ColorSingleton shareSingleton].cellLineColor;
        view.normalBackgroundColor = [ColorSingleton shareSingleton].cellLineColor;
    }];
}
- (void)setLikeMod:(LikeModel *)likeMod
{
    if (_likeMod != likeMod) {
        [_likeMod release];
        _likeMod = [likeMod retain];
    }
    
    NSURL *url = [NSURL URLWithString:self.likeMod.Avatar];
    [self.imageV sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"detail_touxiang@2x.png"]];
    
    self.nameL.text = self.likeMod.Nickname;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
